<%-- 
    Document   : adminPage
    Created on : Sep 22, 2012, 8:35:03 AM
    Author     : lion
--%>

<%@page import="entities.Faculty"%>
<%@page import="dao.FacultyDao"%>
<%@page import="java.util.Iterator"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <headF
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link  href="../../style.css" rel="stylesheet" type="text/csss"/>
        <script type="text/javascript" src="../../../js/toggle.js"></script>
        <script type="text/javascript" src="../../../js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="../../../js/jquery.validate.min.js"></script>
        <style type="text/css">
            table{
                border-collapse:collapse;
                width: 100%;
                text-align: center;
            }
            table,th, td
            {
                border: 1px solid black;
            }
            th{
                height: 50px;
            }
        </style>
        <script type="text/javascript">
            $(document).ready(function(){
                $("#frmEdit").validate();
            });
        </script>
        <title>Edit faculty</title>
    </head>
    <body>
        <div class="body">
            <%@include file="../../template/header.html" %>
            <%@include file="../../../template/displayMessage.jsp"%>
            <%@include file="sidebar.html"%>
            <div id="contentbox">
                <table border="0">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Course Id</th>
                            <th>Member Id</th>
                            <th>Name</th>
                            <th>Address</th>
                        </tr>
                    </thead>
                    <tbody>
                        <% FacultyDao facultyDao = new FacultyDao();
                            for (Iterator it = facultyDao.getFacultyList().iterator(); it.hasNext();) {
                                Faculty faculty = (Faculty) it.next();
                                String url = "editFaculty.jsp?facultyid=" + faculty.getFacultyid();
                        %>

                        <tr>
                            <td><a href=<%=url%> ><%=faculty.getFacultyid()%></a></td>
                            <td><%=faculty.getCourseid()%></td>
                            <td><%=faculty.getMemberid()%></td>
                            <td><%=faculty.getName()%></td>
                            <td><%=faculty.getAddress()%></td>
                        </tr>
                        <% }%>
                    </tbody>
                </table>
                <br/>

                <%
                    if (request.getQueryString() != null) {
                        for (Iterator it = facultyDao.findFaculty(request.getQueryString()).iterator(); it.hasNext();) {
                            Faculty f = (Faculty) it.next();%>
                            <form action="../../../EditFacultyServlet" method="post" id="frmEdit">
                                <table style="width:0%;">
                        <tr>
                            <td>Faculty id</td>
                            <td><input type="text" value="<%= f.getFacultyid()%>" name="txtFacultyID" readonly="true" class="required"/></td>
                        </tr>
                        <tr>
                            <td>Course id</td>
                            <td> <input type="text" value="<%= f.getCourseid()%>" name="txtCourseid" class="required"/></td>
                        </tr>
                        <tr>
                            <td>Member id</td>
                            <td><input type="text" value="<%= f.getMemberid()%>" name="txtMemberid" class="required"/></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td> <input type="text" value="<%= f.getName()%>" name="txtName" class="required"/></td>
                        </tr>
                        <tr>
                            <td>Address</td>
                            <td> <input type="text" value="<%= f.getAddress()%>" name="txtAddress" class="required"/></td>
                        </tr>
                    </table>
                        <input type="submit" name="Submit"/>
                </form>
                <% }
                    }%>
            </div>
            <div class="clear"></div>
            <%@include file="../../../template/displayUser.jsp" %>
            <%@include file="../../template/footer.html" %>
        </div>
    </body>
</html>
